current_dir=$(pwd)

echo "check dir... ..."
if [ ! -d "/usr/local/etc" ]; then
	mkdir -p /usr/local/etc
fi

if [ ! -d "/usr/local/openssh/bin" ]; then
	mkdir -p /usr/local/openssh/bin
fi

if [ ! -d "/usr/local/libexec" ]; then
	mkdir -p /usr/local/libexec
fi

if [ ! -d "/var/run" ]; then
	mkdir -p /var/run
fi

if [ ! -d "/var/empty" ]; then
	mkdir -p /var/empty
fi

echo "move file... ..."
mv ${current_dir}/bin/* /usr/local/openssh/bin
mv ${current_dir}/etc/* /usr/local/etc
mv ${current_dir}/libexec/* /usr/local/libexec
mv ${current_dir}/sbin/sshd /sbin/sshd
mv ${current_dir}/sbin/sshd.sh /etc/init.d/sshd
mv ${current_dir}/key.sh /usr/local/etc
mv ${current_dir}/lib/* /lib

echo "cread ln... ..."
cd /bin
ln -s /usr/local/openssh/bin/scp
ln -s /usr/local/openssh/bin/sftp
ln -s /usr/local/openssh/bin/ssh
ln -s /usr/local/openssh/bin/ssh-add
ln -s /usr/local/openssh/bin/ssh-agent
ln -s /usr/local/openssh/bin/ssh-keygen
ln -s /usr/local/openssh/bin/ssh-keyscan
